<%--
  Created by IntelliJ IDEA.
  User: 86131
  Date: 2022/4/4
  Time: 19:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<html>
<head>
    <title>添加</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.5/css/layui.css">
    <script src="https://www.layuicdn.com/layui-v2.5.5/layui.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <style>
        input{
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<div class="top-nav">
    <ul class="layui-nav" lay-bar="disabled">
        <li class="layui-nav-item">
            <a href="${pageContext.request.contextPath}/domain/main.jsp" target="iframe">浏览</a>
        </li>

        <li class="layui-nav-item">
            <a href="${pageContext.request.contextPath}/add" target="iframe">添加</a>
        </li>

        <li class="layui-nav-item" lay-unselect="" style="margin-left: 70%">
            <span>${teacher}</span>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;">子级菜单</a></dd>
                <dd><a href="javascript:;">横线隔断</a></dd>
                <hr>
                <dd style="text-align: center;"><a href="/logout">退出</a></dd>
            </dl>
        </li>
    </ul>
</div>
<div id="add_stu_box" style="margin-left: 45%;margin-top: 130px">
    <h2 style="margin-left: 60px;margin-bottom: 8px">添加</h2>
    <form id="add_box">
        <input type="text" name="stu_id" placeholder="学号" id="stu_id"><br>
        <input type="text" name="stu_name" placeholder="姓名" id="stu_name" ><br>
<%--        <input type="text" name="stu_sex" placeholder="性别" id="stu_sex"><br>--%>
        <input type="radio" name="stu_sex" value="man" title="男" checked="">男
        <input type="radio" name="stu_sex" value="女" title="女"> 女<br>
        <input type="text" name="chinese" placeholder="语文" id="chinese" ><br>
        <input type="text" name="math" placeholder="数学" id="math" ><br>
        <input type="text" name="english" placeholder="英语" id="english" ><br>
        <input type="text" name="sci_total" placeholder="理综" id="sci_total" ><br>
        <input type="text" name="total" placeholder="总分" id="total" readonly="readonly"><br>
        <button type="button" class="btn btn-default" title="添加" data-toggle="modal"
                data-target="#addOrEditModal" onclick="addStudent()"> 添加信息
        </button>
    </form>


    <button class="" onclick="total()"  style="margin-left: 120px;margin-top: -22px;background-color: darkcyan;color: white">计算总分</button>
</div>
<script>
    layui.use('element', function(){
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        //监听导航点击
        element.on('nav(demo)', function(elem){
            layer.msg(elem.text());
        });
    });

    function total() {
        var chinese=parseInt($("#chinese").val());
        var math=parseInt($("#math").val());
        var english=parseInt($("#english").val());
        var sci_tatal=parseInt($("#sci_total").val());
        var sum=chinese+math+english+sci_tatal;
        var total=$("#total").val(sum);
    }
    function addStudent() {
        var url = "${pageContext.request.contextPath}/addStudent";
        alert("123");
        alert(url);
        var x=$("#add_box").serialize()
        alert(x);
        $.post(url, $("#add_box").serialize(), function (response) {
            alert(response.message)
            if (response.success == true) {
                alert("good");
                window.location.href = getProjectPath()+"/allStudents";
            }
        })

    }
</script>
</body>
</html>
